﻿@page
@model IndexModel
@{
    ViewData["Title"] = "Message System";
}

<h1>@ViewData["Title"]</h1>

<div class="row">
    <div class="col-md-8">

        <form method="post">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Add a message</h3>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <label asp-for="Message.Text"></label>
                        <input asp-for="Message.Text" class="form-control" style="width:70%;margin-bottom:5px">
                        <span asp-validation-for="Message.Text" class="text-danger"></span>
                    </div>
                    <div class="form-group">
                        <button type="submit" asp-page-handler="AddMessage" class="btn btn-default">Add Message</button>
                    </div>
                </div>
            </div>
        </form>

    </div>
</div>

<div class="row">
    <div class="col-md-8">

        <form method="post">
            <div class="panel panel-default">
                <div class="panel-heading clearfix">
                    <button type="submit" asp-page-handler="DeleteAllMessages" class="pull-right btn btn-danger">Clear All</button>
                    <h3 class="panel-title" style="line-height:2.1">Messages</h3>
                </div>
                <div class="panel-body">
                    <ul>
                        @foreach (var message in Model.Messages)
                        {
                            <li style="line-height:2.4">
                                <button type="submit" class="btn btn-danger" style="margin-bottom:2px" asp-page-handler="DeleteMessage" asp-route-id="@message.Id">Delete</button>
                                @message.Text
                            </li>
                        }
                    </ul>
                </div>
            </div>
        </form>

    </div>
</div>

<div class="row">
    <div class="col-md-8">

        <form method="post">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Analyze Messages</h3>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <button type="submit" asp-page-handler="AnalyzeMessages" class="btn btn-default">Analyze</button>
                    </div>
                    <div class="form-group">
                        @Model.MessageAnalysisResult
                    </div>
                </div>
            </div>
        </form>

    </div>
</div>
